/*
 * Copyright (c) Extreme Vision Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef COMMON_DET_INFER_H
#define COMMON_DET_INFER_H
#include "opencv2/core.hpp"
#include <map>
#include <memory>
#include <mutex>
#include "configuration.hpp"
#include "evdeploy/deploy.h"

using namespace ev;

class SampleDetector
{
  public:
    SampleDetector();
    ~SampleDetector();
    /**
     * 算法初始化
     * @param config 算法的相关配置
     * @return 返回初始化结果
     * @attention 参数类型与数量，开发者按需修改
    */
    bool Init(ModelConfig *config);
    /**
     * 算法处理单帧图片
     * @param img 图片输入
     * @param det_results 图片的检测结果
     * @return 返回算法执行的结果
     * @attention 返回结果的类型，开发者应按照算法的实际结果定义相应的类型
    */
    bool ProcessImage(const cv::Mat &img, std::vector<ev::vision::BoxInfo> &det_results);

    /**
     * uninit算法
    */
    bool UnInit();

  private:
    vision::YOLOv5Preprocessor m_preprocessor;
    vision::YOLOv5Postprocessor m_postprocessor;
    ModelConfig *m_model_config{nullptr};
};

#endif
